﻿using Microsoft.Data.SqlClient;
using System.Configuration;
using UsedBook.DAL;
using UsedBook.Models;

BookDAL bookDAL = new BookDAL();
var books =  bookDAL.GetBooks();
foreach (var book_item in books)
{
    Console.WriteLine(book_item.Title);
}
Book book = bookDAL.GetBookById(6);
Console.WriteLine(book.Title);

UserDAL userDAL = new UserDAL();
var users = userDAL.GetAllUsers();
foreach (var user in users)
{
    Console.WriteLine($"{user.UserId}\t{user.UserName}\t{user.Pwd}\t{user.Email}\t{user.Phone}\t{user.UserRole}\t{user.CreateAt}");
}
var userOne = userDAL.GetUserById(1);
if(userOne.UserId==0) Console.WriteLine("用户不存在");
//Console.WriteLine($"{userOne.UserId}\t{userOne.UserName}\t{userOne.Pwd}\t{userOne.Email}\t{userOne.Phone}\t{userOne.UserRole}\t{userOne.CreateAt}");

//var ifDelete = userDAL.DeleteUserById(1);
//if (ifDelete)
//{
//    Console.WriteLine("成功删除");
//}
//else
//{
//    Console.WriteLine("删除不成功");
//}